/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package rest.jbpm.wrappers;

import java.util.Date;
import javax.xml.bind.annotation.*;
import org.jbpm.api.history.HistoryProcessInstance;
import rest.jbpm.wrappers.lists.HistoryVariableList;

/**
 *
 * @author jump
 */

@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
@XmlType(name = "historyProcess", propOrder = {
    "processInstanceId",
    "processDefinitionId",
    "key",
    "state",
    "startTime",
    "endTime",
    "endActivityName",
    "duration",
    "variables"
})
public class HistoryProcess {

    private long duration;
    private String endActivityName;
    private Date endTime;
    private Date startTime;
    private String key;
    private String processDefinitionId;
    private String processInstanceId;
    private String state;
    private HistoryVariableList variables;

    protected HistoryProcess() {
        
    }

    public HistoryProcess(HistoryProcessInstance hpi, HistoryVariableList variables) {

        this.duration = hpi.getDuration() != null ? hpi.getDuration() : 0;
        this.endActivityName = hpi.getEndActivityName();
        this.endTime = hpi.getEndTime();
        this.key = hpi.getKey();
        this.processDefinitionId = hpi.getProcessDefinitionId();
        this.processInstanceId = hpi.getProcessInstanceId();
        this.startTime = hpi.getStartTime();
        this.state = hpi.getState();
        this.variables = variables;

    }

    @XmlElement(required = false)
    public long getDuration() {
        return duration;
    }

    @XmlElement(required = false)
    public String getEndActivityName() {
        return endActivityName;
    }

    @XmlElement(required = false)
    public Date getEndTime() {
        return endTime;
    }

    @XmlElement(required = false)
    public String getKey() {
        return key;
    }

    @XmlElement(required = true)
    public String getProcessDefinitionId() {
        return processDefinitionId;
    }

    @XmlElement(required = true)
    public String getProcessInstanceId() {
        return processInstanceId;
    }

    @XmlElement(required = true)
    public Date getStartTime() {
        return startTime;
    }

    @XmlElement(required = true)
    public String getState() {
        return state;
    }

    @XmlElement(required = false)
    public HistoryVariableList getVariables() {
        return variables;
    }

}
